<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
    <script>
    var squre = function (i) {
        return i*i;
    }

    var double = function (i) {
        return i*2;
    }

    function handle(list,func) {
        return list.map(func);
    }

    console.log(handle([1,2,3,4,5,6],squre));
    console.log(handle([1,2,3,4,5,6],double));

    function curryAdd(a) {
        return function (b) {
            return function (c) {
                return function (d) {
                    return a+b+c+d;
                }
            }
        }
    }

    console.log(curryAdd(1)(2)(3)(4)); //- > 10

    function add (a,b,c,d) {
        return a+b+c+d;
    }

    console.log(add(1,2,3,4));//-> 10


    {
        // 1.add(2).reduce(3).add(4)

        Number.prototype.add = function (n) {
            return this + n;
        }

        Number.prototype.reduce = function (m) {
            return this - m;
        }

        console.log((1).add(2).reduce(3).add(4));


    }
    

   
    </script>
</body>
</html>